﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Windows.Data;

namespace FRL.DebtChased.Controls
{
    public partial class RatesAndInstructionBatchesCtrl : UserControl, INotifyPropertyChanged
    {

        #region Constructor
        public RatesAndInstructionBatchesCtrl()
        {
            InitializeComponent();
            this.LayoutRoot.DataContext = this;
            RaisePropertyChanged("RecordTabs");
        }
        #endregion

        #region Temp Tab Handling
        public IEnumerable<TabItem> RecordTabs
        {
            get
            {
                List<TabItem> tabs = new List<TabItem>();
                tabs.Add(new TabItem() { Header = "*New*" });
                return tabs;
            }
        }
        private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }
        #endregion

        #region INotifyPropertyChanged handlers
        public event PropertyChangedEventHandler PropertyChanged;
        public void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion

        #region Record Control
        private bool _isRecordEditable;
        public bool IsRecordEditable
        {
            get { return _isRecordEditable; }
            set
            {
                if (value != _isRecordEditable)
                {
                    _isRecordEditable = value;
                    RaisePropertyChanged("IsRecordEditable");
                    RaisePropertyChanged("EditRecordVisibility");
                    RaisePropertyChanged("ViewRecordVisibility");
                }
            }
        }
        public Visibility EditRecordVisibility
        {
            get { return _isRecordEditable ? Visibility.Visible : Visibility.Collapsed; }
        }
        public Visibility ViewRecordVisibility
        {
            get { return _isRecordEditable ? Visibility.Collapsed : Visibility.Visible; }
        }

        #endregion

        #region Form Event Handlers
        private GridLength _gridLengthZero = new GridLength(0);
        private GridLength _gridLengthAuto = new GridLength(1, GridUnitType.Auto);

        private void HeaderBar_ExpandChange(object sender, EventArgs e)
        {
            HeaderBar.IsArrowUp = !HeaderBar.IsArrowUp;
            Body.Visibility = HeaderBar.IsArrowUp ? Visibility.Visible : Visibility.Collapsed;
        }
        private void ToggleEditView_Click(object sender, EventArgs e)
        {
            IsRecordEditable = !IsRecordEditable;
        }

        private void butRequestModification_Click(object sender, EventArgs e)
        {

        }

        private void cboContact_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }
        #endregion

    }
}
